Python - Challenge 1
Code Life
By Pierre Marsaa
Safe Stats Viewer - Get Stat Safely
Start building a safe stats viewer!
- Create get_stat(codemon, stat_name) that uses try/except to handle KeyError
- If stat exists: return the value
- If stat doesn't exist: print "[stat_name] not found!" and return 0
- Test by getting existing stats (attack) and non-existing stats (speed)
↗️
Loading editor...
↶
↷
💡 Show Solution
Continue